﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Dashboard : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadLogin();
            lblBalance.Text += SendSMS.remainingSMS(getLoginID())+" SMS";
        }
    }


    private void loadLogin()
    {
        if (hfLoginID.Value == "")
        {
            hfLoginID.Value = getLogin().ToString();
        }
    }

    private string getLoginID()
    {
        return hfLoginID.Value.Substring(6, hfLoginID.Value.Length - 6).Substring(0, hfLoginID.Value.Length - 12);


    }
    private string getLogin()
    {
        string loginID = "";
        try
        {
            if (Session["OnlineSMS_LoginID"] != null)
            {
                loginID = Session["OnlineSMS_LoginID"].ToString();
            }
            else if (hfLoginID.Value != "")
            {
                loginID = hfLoginID.Value;
            }
            else
            {
                Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("Default.aspx");
            }

        }
        catch (Exception ex)
        { }

        return loginID;
    }

}